package Top200;

/**
 * @author zhangmin
 * @create 2022-02-24 15:15
 */
public class addBinary67 {
    public String addBinary(String a, String b) {
        int i=a.length()-1,j=b.length()-1;
        String res="";
        int pre=0;
        while (i>=0||j>=0||pre>0){
            int num1=i>=0?a.charAt(i)-'0':0;
            int num2=j>=0?b.charAt(j)-'0':0;
            int sum=num1+num2+pre;
            pre=sum/2;
            res=(sum%2)+res;
            i--;j--;
        }
        return res;
    }
}
